import { constantRoutes } from '@/router'
import { Module } from 'vuex'
import { permissionStateTypes, RootStateTypes } from './interface'

const parmissionModule: Module<permissionStateTypes, RootStateTypes> = {
  namespaced: true,
  state: {
    roles: '', // 用户包含的角色,
    permissions: [], // 用户指定局部操作权限
    accessRoutes: constantRoutes, // 可访问路由集合
    routes: constantRoutes, // 所有路由集合
    authedRoutes: []
  },
  mutations: {},
  actions: {},
  getters: {
    getAccessRoutes(state: permissionStateTypes) {
      return state.routes
    },
    authedRoutes(state: permissionStateTypes) {
      return state.authedRoutes
    },
    getRoles(state: permissionStateTypes) {
      return state.roles
    },
    getPermission(state: permissionStateTypes) {
      return state.permissions
    }
  }
}
